import 'package:fate_blind_box/theme/theme_color.dart';
import 'package:fate_blind_box/utils/common_widget.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'home_act_list_controller.dart';
import 'home_act_list_page.dart';

class HomeActTabPage extends StatefulWidget {
  const HomeActTabPage({Key? key}) : super(key: key);

  @override
  State<HomeActTabPage> createState() => _MyActTabPageState();
}

class _MyActTabPageState extends State<HomeActTabPage>
    with SingleTickerProviderStateMixin {
  late TabController importTabController;
  List<String> tabList = ['未来热门','今日盛典', '往期回顾'];
  double tabFontSize = 16.0;
  HomeActListController bindController = Get.put(HomeActListController());

  @override
  Widget build(BuildContext context) {
    return AppWidget.navTitleBar(
      bgColor: ThemeColor.sendMsgColor,
      appBarColor: ThemeColor.sendMsgColor,
      title: '相亲活动',
      childWidget: Column(
        children: [
          SizedBox(
            height: 40,
            child: TabBar(
              tabs: getTabList(),
              controller: importTabController,
              labelColor: ThemeColor.black3D3D3DColor,
              unselectedLabelColor: ThemeColor.grayA0A0A0Color,
              indicatorSize: TabBarIndicatorSize.label,
              indicatorColor: ThemeColor.appColor,
              unselectedLabelStyle: TextStyle(
                fontSize: tabFontSize,
              ),
              // 未选择样式
              labelStyle: TextStyle(
                  fontSize: tabFontSize, fontWeight: FontWeight.w500), // 选择的样式
            ),
          ),
          Container(
            height: 0.5,
            color: ThemeColor.lineColor,
          ),
          GetBuilder(
            id: bindController.tabListViewId,
            builder: (HomeActListController controller) {
              return Expanded(
                child: TabBarView(controller: importTabController, children:  [
                  HomeActListPage(dataList: controller.futureList,),
                  HomeActListPage(dataList: controller.todayList,),
                  HomeActListPage(dataList: controller.pastList,),
                ]),
              );
            }
          ),
        ],
      ),
    );
  }

  //组装tab
  List<Widget> getTabList() {
    List<Widget> list =
        List.generate(tabList.length, (index) => Tab(text: tabList[index]));
    return list;
  }

  @override
  void initState() {
    super.initState();
    importTabController = TabController(length: tabList.length, vsync: this);
    bindController.getTabListData();
  }
}
